Skip to content

feat(FR-2606): restore BUI i18n context isolation under Vite dep optimization#6870

Merged
graphite-app[bot] merged 1 commit intomainfrom
04-20-feat_fr-2606_restore_bui_i18n_context_isolation_under_vite_dep_optimization
Apr 30, 2026
Merged

feat(FR-2606): restore BUI i18n context isolation under Vite dep optimization#6870
graphite-app[bot] merged 1 commit intomainfrom
04-20-feat_fr-2606_restore_bui_i18n_context_isolation_under_vite_dep_optimization

Conversation

@nowgnuesLee
Copy link
Copy Markdown
Contributor

@nowgnuesLee nowgnuesLee commented Apr 22, 2026

Resolves #6809(FR-2606)

Summary

Follow-up fix after the initial Vite PoC uncovered that BUI's i18n instance was bleeding into the host app.

Root cause: BUI intentionally maintains its OWN i18n singleton (see BAIConfigProvider's <I18nextProvider i18n={buiI18n}>). Under pnpm's per-package copies (split by TypeScript peer version), the two react-i18next copies had different React Context objects, so BUI's Provider published to its own Context and the host read from its own Context. Clean isolation.

Under Vite's default dep optimizer the two copies were collapsed into a single bundled module → one Context object → BUI's Provider leaked, and host components resolved their keys against BUI's (BUI-only) resource set, rendering raw keys.

Fix: optimizeDeps.exclude: ['i18next', 'react-i18next'] preserves natural pnpm-per-package resolution so the two Context objects stay distinct.

Test plan

  • Raw i18n keys no longer render on login/dashboard under vite:dev
  • BUI's own keys still resolve via BUI's Provider
  • Host's own keys resolve via host's Provider

Stack

Builds on FR-2606 PoC phase 1. Continues the Vite migration series.

@github-actions github-actions Bot added the size:L 100~500 LoC label Apr 22, 2026
Copy link
Copy Markdown
Contributor Author

nowgnuesLee commented Apr 22, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • flow:merge-queue - adds this PR to the back of the merge queue
  • flow:hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@nowgnuesLee nowgnuesLee force-pushed the 04-20-feat_fr-2606_vite_poc_phase_1_dev_server_hmr_react_compiler_parity branch from bf0e617 to 7cb1e84 Compare April 27, 2026 13:57
@nowgnuesLee nowgnuesLee force-pushed the 04-20-feat_fr-2606_restore_bui_i18n_context_isolation_under_vite_dep_optimization branch from 5536f7b to 7d337b6 Compare April 27, 2026 13:57
@nowgnuesLee nowgnuesLee marked this pull request as ready for review April 28, 2026 04:25
Copilot AI review requested due to automatic review settings April 28, 2026 04:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores Backend.AI WebUI host-app i18n context isolation from backend.ai-ui under Vite’s dependency optimization, preventing BUI’s I18nextProvider from leaking into the host tree during dev.

Changes:

  • Exclude i18next / react-i18next from Vite dep optimization to preserve pnpm’s per-package module instances (and thus separate React Contexts).
  • Add Vite resolve aliases to ESM shim modules for CJS-only transitive deps (void-elements, use-sync-external-store/shim) that would otherwise break when optimization is skipped.
  • Document the i18n isolation root cause/fix in Vite PoC notes and add a Playwright smoke test as a regression reproducer.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
react/vite.config.ts Excludes i18n deps from optimizeDeps and adds shim aliases; clarifies dedupe intent for other shared singletons.
react/vite-shims/void-elements.mjs Provides an ESM default-export shim for the CJS-only void-elements package.
react/vite-shims/use-sync-external-store-shim.mjs Provides an ESM shim exporting React’s native useSyncExternalStore for the CJS-only shim entrypoint.
react/VITE_POC_NOTES.md Adds Phase 1 documentation detailing the i18n context isolation issue and the adopted fix.
e2e/vite-poc-smoke.spec.ts Adds a smoke test intended to guard against the i18n leakage regression during the Vite PoC.

Comment thread e2e/vite-poc-smoke.spec.ts
Comment thread e2e/vite-poc-smoke.spec.ts
Comment thread e2e/vite-poc-smoke.spec.ts
Comment thread e2e/vite-poc-smoke.spec.ts
@nowgnuesLee nowgnuesLee force-pushed the 04-20-feat_fr-2606_vite_poc_phase_1_dev_server_hmr_react_compiler_parity branch from 7cb1e84 to c115607 Compare April 28, 2026 05:02
@nowgnuesLee nowgnuesLee force-pushed the 04-20-feat_fr-2606_restore_bui_i18n_context_isolation_under_vite_dep_optimization branch 2 times, most recently from 5e5dc8f to ef09849 Compare April 28, 2026 05:15
@yomybaby yomybaby force-pushed the 04-20-feat_fr-2606_restore_bui_i18n_context_isolation_under_vite_dep_optimization branch from ef09849 to 906250d Compare April 30, 2026 12:08
@yomybaby yomybaby force-pushed the 04-20-feat_fr-2606_vite_poc_phase_1_dev_server_hmr_react_compiler_parity branch from c115607 to 7807fa6 Compare April 30, 2026 12:08
@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented Apr 30, 2026

Merge activity

…mization (#6870)

Resolves #6809(FR-2606)

## Summary

Follow-up fix after the initial Vite PoC uncovered that BUI's i18n instance was bleeding into the host app.

**Root cause**: BUI intentionally maintains its OWN i18n singleton (see `BAIConfigProvider`'s `<I18nextProvider i18n={buiI18n}>`). Under pnpm's per-package copies (split by TypeScript peer version), the two `react-i18next` copies had *different* React Context objects, so BUI's Provider published to its own Context and the host read from its own Context. Clean isolation.

Under Vite's default dep optimizer the two copies were collapsed into a single bundled module → one Context object → BUI's Provider leaked, and host components resolved their keys against BUI's (BUI-only) resource set, rendering raw keys.

**Fix**: `optimizeDeps.exclude: ['i18next', 'react-i18next']` preserves natural pnpm-per-package resolution so the two Context objects stay distinct.

## Test plan

- [x] Raw i18n keys no longer render on login/dashboard under `vite:dev`
- [x] BUI's own keys still resolve via BUI's Provider
- [x] Host's own keys resolve via host's Provider

## Stack

Builds on FR-2606 PoC phase 1. Continues the Vite migration series.
@graphite-app graphite-app Bot force-pushed the 04-20-feat_fr-2606_vite_poc_phase_1_dev_server_hmr_react_compiler_parity branch from 7807fa6 to 4ac49a9 Compare April 30, 2026 12:12
@graphite-app graphite-app Bot force-pushed the 04-20-feat_fr-2606_restore_bui_i18n_context_isolation_under_vite_dep_optimization branch from 906250d to 3e8d20c Compare April 30, 2026 12:13
Base automatically changed from 04-20-feat_fr-2606_vite_poc_phase_1_dev_server_hmr_react_compiler_parity to main April 30, 2026 12:23
@graphite-app graphite-app Bot merged commit 3e8d20c into main Apr 30, 2026
4 checks passed
@graphite-app graphite-app Bot deleted the 04-20-feat_fr-2606_restore_bui_i18n_context_isolation_under_vite_dep_optimization branch April 30, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vite PoC Phase 1: dev server + HMR parity for react/ and backend.ai-ui

2 participants